import type { RouteRecordRaw } from 'vue-router'

export interface AppRouteMeta {
  title: string
  icon?: string
  roles?: string[]
  keepAlive?: boolean
  hidden?: boolean
}

export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta' | 'children'> {
  meta: AppRouteMeta & RouteRecordRaw['meta']
  children?: AppRouteRecordRaw[]
}

const BlankView = () => import('../layouts/BlankRouterView.vue')

export const appChildRoutes: AppRouteRecordRaw[] = [
  {
    path: 'dashboard',
    name: 'Dashboard',
    component: () => import('../views/dashboard/DashboardHome.vue'),
    meta: {
      title: '首页概览',
      icon: 'DataBoard',
      roles: ['ADMIN', 'EDU_ADMIN', 'TEACHER']
    }
  },
  {
    path: 'profile',
    name: 'UserProfile',
    component: () => import('../views/profile/UserProfile.vue'),
    meta: {
      title: '个人信息',
      icon: 'User',
      roles: ['ADMIN', 'EDU_ADMIN', 'TEACHER']
    }
  },
  {
    path: 'system',
    name: 'System',
    component: BlankView,
    meta: { title: '系统管理', icon: 'Setting', roles: ['ADMIN'] },
    children: [
      {
        path: 'accounts',
        name: 'SystemAccounts',
        component: () => import('../views/system/AccountManagement.vue'),
        meta: { title: '开通账户', icon: 'User', roles: ['ADMIN'] }
      },
      {
        path: 'roles',
        name: 'SystemRoles',
        component: () => import('../views/system/RoleManagement.vue'),
        meta: { title: '角色管理', icon: 'CollectionTag', roles: ['ADMIN'] }
      },
      {
        path: 'authorizations',
        name: 'SystemAuthorizations',
        component: () => import('../views/system/AccountAuthorization.vue'),
        meta: { title: '账户授权', icon: 'UserFilled', roles: ['ADMIN'] }
      }
    ]
  },
  {
    path: 'users',
    name: 'Users',
    component: BlankView,
    meta: { title: '用户管理', icon: 'Avatar', roles: ['ADMIN', 'EDU_ADMIN'] },
    children: [
      {
        path: 'students',
        name: 'StudentManagement',
        component: () => import('../views/users/StudentManagement.vue'),
        meta: { title: '学生管理', icon: 'Reading', roles: ['ADMIN', 'EDU_ADMIN'] }
      },
      {
        path: 'teachers',
        name: 'TeacherManagement',
        component: () => import('../views/users/TeacherManagement.vue'),
        meta: { title: '老师管理', icon: 'Notebook', roles: ['ADMIN', 'EDU_ADMIN'] }
      }
    ]
  },
  {
    path: 'academic',
    name: 'Academic',
    component: BlankView,
    meta: { title: '教务管理', icon: 'Management', roles: ['ADMIN', 'EDU_ADMIN'] },
    children: [
      {
        path: 'classrooms',
        name: 'ClassroomManagement',
        component: () => import('../views/academic/ClassroomManagement.vue'),
        meta: { title: '教室管理', icon: 'School', roles: ['ADMIN', 'EDU_ADMIN'] }
      },
      {
        path: 'courses',
        name: 'CourseManagement',
        component: () => import('../views/academic/CourseManagement.vue'),
        meta: { title: '课程管理', icon: 'Memo', roles: ['ADMIN', 'EDU_ADMIN'] }
      },
      {
        path: 'academic-years',
        name: 'AcademicYearManagement',
        component: () => import('../views/academic/AcademicYearManagement.vue'),
        meta: { title: '学年管理', icon: 'Calendar', roles: ['ADMIN', 'EDU_ADMIN'] }
      },
      {
        path: 'classes',
        name: 'ClassManagement',
        component: () => import('../views/academic/ClassManagement.vue'),
        meta: { title: '班级管理', icon: 'Collection', roles: ['ADMIN', 'EDU_ADMIN'] }
      }
    ]
  }
]
